<style>
.label_box{width:430px;}
.label{height:30px;padding:0 10px;}
.label li{float:left;line-height:30px;margin-right:15px;}
</style>
<div class="label_box" style="display:none">
  <ul class="label"></ul>
</div>
<span><input type="hidden" name="tags" value="<?php echo $data->tags ?>" />新增标签：<input type="text" value="" class="input length_2" id="addtags"/> <input type="button" class="btn  mr10 addtags" value="添加" /></span>
<script>
var _length = 0;
$(function(){
	var tagsList = <?php echo json_encode(strpos($data->tags, ',') !== false ? explode(',', $data->tags) : explode(' ', $data->tags)); ?>;
	if(tagsList.length > 0){
		$.each(tagsList,function(i,tag){
			if(tag == '' || tag == undefined){
				return false;
			}
			addTag(tag);
		});
	}
	$('.addtags').click(function(){
		var tag = $('#addtags').val();
		if(tag != ''){
			$('#addtags').val('');
			addTag(tag);
			getTag();
		}
	});
});
//tag
function taglist(li){
	Wind.use("artDialog", "iframeTools", function () {
		var tag = $('#li_'+li+' input[name="tags[]"]').val();
		if(tag == '' || tag == undefined){
			return false;
		}
		art.dialog.open('<?php echo $staticUrl; ?>admin/public/tags.html?tag='+tag, {
            title: '信息列表',
            id: 'taglist',
            lock: true,
            fixed: true,
			width:700,
			height:560,
            background: "#CCCCCC",
            opacity: 0
        });
	});
}
//添加标签
function addTag(tag){
	$('div.label_box').show();
	$('ul.label').append('<li id="li_'+_length+'"><a href="javascript:;" onclick="taglist('+_length+');">'+tag+'</a><img src="<?php echo $staticUrl; ?>statics/images/admin/label_03.png" class="label-pic" onclick="deletes('+_length+');"><input type="hidden" name="tags[]" value="'+tag+'" /></li>');
    _length ++;
}
//取消
function deletes(li){
	$('#li_'+li).remove();
	getTag();
}
//获取标签值
function getTag(){
	var tag = '';
	$.each($('input[name="tags[]"]'),function(i,r){
		if(tag == ''){
			tag += $(this).val();
		}else{
			tag += " "+$(this).val();
		}
	});
	$('input[name="tags"]').val(tag);
}
</script>